/**
 * @param {string} s
 * @param {string} t
 * @return {boolean}
 */
var backspaceCompare = function(s, t) {
  let resultS = [], resultT = [];
  for(let i = 0; i < s.length; i++) {
    if(s[i] != '#') {
      resultS.push(s[i]);
    } else {
      resultS.pop();
    }
  }
  for(let i = 0; i < t.length; i++) {
    if(t[i] != '#') {
      resultT.push(t[i]);
    } else {
      resultT.pop();
    }
  }
  if(resultS.length != resultT.length) return false;
  for(let i = 0; i < resultS.length; i++) {
    if(resultS[i] != resultT[i]) return false;
  }
  return true;
};
let s = "ab#c", t = "ad#c";
console.log(backspaceCompare(s, t));
s = "ab##", t = "c#d#";
console.log(backspaceCompare(s, t));
s = "a#c", t = "b";
console.log(backspaceCompare(s, t));
